package com.sww.pj.sys.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sww.pj.common.utils.ShiroUtils;
import com.sww.pj.sys.pojo.SysUser;
import com.sww.pj.sys.pojo.SysUserMenu;
import com.sww.pj.sys.service.SysMenuService;

@Controller
@RequestMapping("/")
public class PageController {
	
	@RequestMapping("doLoginUI")
	public String doLoginUI(){
        return "login";

	}
	
	@Autowired
	private SysMenuService sysMenuService;
	@RequestMapping("/doIndexUI")
	public String doIndexUI(Model model) {
		SysUser user=ShiroUtils.getUser();
		List<SysUserMenu> userMenus = sysMenuService.findUserMenus(user.getId());
		model.addAttribute("user",user);
		model.addAttribute("userMenus",userMenus);
	
		return "starter";
	}
	@RequestMapping("doPageUI")
	public String doPageUI() {
		return "common/page";
	}
	//rest风格
	//	跳转到目录下的文件
	@RequestMapping("{module}/{moduleUI}")
	public String doModuleUI(@PathVariable String moduleUI) {
		return "sww/"+moduleUI;
	}
}
